package homework.test01;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

public class demo03 {
    public static void main(String[] args) {
        HashMap<Integer, String> map = new HashMap<>();
        map.put(1, "张三");
        map.put(2, "李四");
        map.put(3, "王五");
        System.out.println("集合大小：" + map.size());


        System.out.println("======键找值=======");
        Set<Integer> integers = map.keySet();
        for (Integer k : integers) {
            String v = map.get(k);
            System.out.println(k + ":" + v);
        }

        System.out.println("======键值对=======");
        Set<Map.Entry<Integer, String>> entries = map.entrySet();
        for (Map.Entry<Integer, String> entry : entries) {
            System.out.println(entry.getKey()+":"+entry.getValue());
        }

        System.out.println("键为1的值:"+map.get(1));
        System.out.println("键为10的值:"+map.get(10));
        System.out.println("判断集合中是否有键：10\t" + map.containsKey(10));

        map.remove(1);

        System.out.println("===Lambda表达式===");
        map.forEach((integer, string) -> System.out.println(integer+":"+string));

    }
}
